//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS EKSAuth service.
///
/// The Amazon EKS Auth API and the AssumeRoleForPodIdentity action are only used by the EKS Pod Identity Agent.
public struct EKSAuth: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the EKSAuth client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "EKSAuth",
            serviceIdentifier: "eks-auth",
            serviceProtocol: .restjson,
            apiVersion: "2023-11-26",
            endpoint: endpoint,
            serviceEndpoints: Self.serviceEndpoints,
            variantEndpoints: Self.variantEndpoints,
            errorType: EKSAuthErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }


    /// custom endpoints for regions
    static var serviceEndpoints: [String: String] {[
        "af-south-1": "eks-auth.af-south-1.api.aws",
        "ap-east-1": "eks-auth.ap-east-1.api.aws",
        "ap-northeast-1": "eks-auth.ap-northeast-1.api.aws",
        "ap-northeast-2": "eks-auth.ap-northeast-2.api.aws",
        "ap-northeast-3": "eks-auth.ap-northeast-3.api.aws",
        "ap-south-1": "eks-auth.ap-south-1.api.aws",
        "ap-south-2": "eks-auth.ap-south-2.api.aws",
        "ap-southeast-1": "eks-auth.ap-southeast-1.api.aws",
        "ap-southeast-2": "eks-auth.ap-southeast-2.api.aws",
        "ap-southeast-3": "eks-auth.ap-southeast-3.api.aws",
        "ap-southeast-4": "eks-auth.ap-southeast-4.api.aws",
        "ap-southeast-5": "eks-auth.ap-southeast-5.api.aws",
        "ap-southeast-7": "eks-auth.ap-southeast-7.api.aws",
        "ca-central-1": "eks-auth.ca-central-1.api.aws",
        "ca-west-1": "eks-auth.ca-west-1.api.aws",
        "cn-north-1": "eks-auth.cn-north-1.api.amazonwebservices.com.cn",
        "cn-northwest-1": "eks-auth.cn-northwest-1.api.amazonwebservices.com.cn",
        "eu-central-1": "eks-auth.eu-central-1.api.aws",
        "eu-central-2": "eks-auth.eu-central-2.api.aws",
        "eu-north-1": "eks-auth.eu-north-1.api.aws",
        "eu-south-1": "eks-auth.eu-south-1.api.aws",
        "eu-south-2": "eks-auth.eu-south-2.api.aws",
        "eu-west-1": "eks-auth.eu-west-1.api.aws",
        "eu-west-2": "eks-auth.eu-west-2.api.aws",
        "eu-west-3": "eks-auth.eu-west-3.api.aws",
        "il-central-1": "eks-auth.il-central-1.api.aws",
        "me-central-1": "eks-auth.me-central-1.api.aws",
        "me-south-1": "eks-auth.me-south-1.api.aws",
        "mx-central-1": "eks-auth.mx-central-1.api.aws",
        "sa-east-1": "eks-auth.sa-east-1.api.aws",
        "us-east-1": "eks-auth.us-east-1.api.aws",
        "us-east-2": "eks-auth.us-east-2.api.aws",
        "us-gov-east-1": "eks-auth.us-gov-east-1.api.aws",
        "us-gov-west-1": "eks-auth.us-gov-west-1.api.aws",
        "us-west-1": "eks-auth.us-west-1.api.aws",
        "us-west-2": "eks-auth.us-west-2.api.aws"
    ]}


    /// FIPS and dualstack endpoints
    static var variantEndpoints: [EndpointVariantType: AWSServiceConfig.EndpointVariant] {[
        [.fips]: .init(endpoints: [
            "af-south-1": "eks-auth-fips.af-south-1.api.aws",
            "ap-east-1": "eks-auth-fips.ap-east-1.api.aws",
            "ap-east-2": "eks-auth-fips.ap-east-2.api.aws",
            "ap-northeast-1": "eks-auth-fips.ap-northeast-1.api.aws",
            "ap-northeast-2": "eks-auth-fips.ap-northeast-2.api.aws",
            "ap-northeast-3": "eks-auth-fips.ap-northeast-3.api.aws",
            "ap-south-1": "eks-auth-fips.ap-south-1.api.aws",
            "ap-south-2": "eks-auth-fips.ap-south-2.api.aws",
            "ap-southeast-1": "eks-auth-fips.ap-southeast-1.api.aws",
            "ap-southeast-2": "eks-auth-fips.ap-southeast-2.api.aws",
            "ap-southeast-3": "eks-auth-fips.ap-southeast-3.api.aws",
            "ap-southeast-4": "eks-auth-fips.ap-southeast-4.api.aws",
            "ap-southeast-5": "eks-auth-fips.ap-southeast-5.api.aws",
            "ap-southeast-7": "eks-auth-fips.ap-southeast-7.api.aws",
            "ca-central-1": "eks-auth-fips.ca-central-1.api.aws",
            "ca-west-1": "eks-auth-fips.ca-west-1.api.aws",
            "cn-north-1": "eks-auth-fips.cn-north-1.api.amazonwebservices.com.cn",
            "cn-northwest-1": "eks-auth-fips.cn-northwest-1.api.amazonwebservices.com.cn",
            "eu-central-1": "eks-auth-fips.eu-central-1.api.aws",
            "eu-central-2": "eks-auth-fips.eu-central-2.api.aws",
            "eu-north-1": "eks-auth-fips.eu-north-1.api.aws",
            "eu-south-1": "eks-auth-fips.eu-south-1.api.aws",
            "eu-south-2": "eks-auth-fips.eu-south-2.api.aws",
            "eu-west-1": "eks-auth-fips.eu-west-1.api.aws",
            "eu-west-2": "eks-auth-fips.eu-west-2.api.aws",
            "eu-west-3": "eks-auth-fips.eu-west-3.api.aws",
            "il-central-1": "eks-auth-fips.il-central-1.api.aws",
            "me-central-1": "eks-auth-fips.me-central-1.api.aws",
            "me-south-1": "eks-auth-fips.me-south-1.api.aws",
            "mx-central-1": "eks-auth-fips.mx-central-1.api.aws",
            "sa-east-1": "eks-auth-fips.sa-east-1.api.aws",
            "us-east-1": "eks-auth-fips.us-east-1.api.aws",
            "us-east-2": "eks-auth-fips.us-east-2.api.aws",
            "us-gov-east-1": "eks-auth-fips.us-gov-east-1.api.aws",
            "us-gov-west-1": "eks-auth-fips.us-gov-west-1.api.aws",
            "us-west-1": "eks-auth-fips.us-west-1.api.aws",
            "us-west-2": "eks-auth-fips.us-west-2.api.aws"
        ])
    ]}

    // MARK: API Calls

    /// The Amazon EKS Auth API and the AssumeRoleForPodIdentity action are only used by the EKS Pod Identity Agent. We recommend that applications use the Amazon Web Services SDKs to connect to Amazon Web Services services; if credentials from an EKS Pod Identity association are available in the pod, the latest versions of the SDKs use them automatically.
    @Sendable
    @inlinable
    public func assumeRoleForPodIdentity(_ input: AssumeRoleForPodIdentityRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> AssumeRoleForPodIdentityResponse {
        try await self.client.execute(
            operation: "AssumeRoleForPodIdentity", 
            path: "/clusters/{clusterName}/assume-role-for-pod-identity", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// The Amazon EKS Auth API and the AssumeRoleForPodIdentity action are only used by the EKS Pod Identity Agent. We recommend that applications use the Amazon Web Services SDKs to connect to Amazon Web Services services; if credentials from an EKS Pod Identity association are available in the pod, the latest versions of the SDKs use them automatically.
    ///
    /// Parameters:
    ///   - clusterName: The name of the cluster for the request.
    ///   - token: The token of the Kubernetes service account for the pod.
    ///   - logger: Logger use during operation
    @inlinable
    public func assumeRoleForPodIdentity(
        clusterName: String,
        token: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> AssumeRoleForPodIdentityResponse {
        let input = AssumeRoleForPodIdentityRequest(
            clusterName: clusterName, 
            token: token
        )
        return try await self.assumeRoleForPodIdentity(input, logger: logger)
    }
}

extension EKSAuth {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: EKSAuth, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
